package generator.statements;

import generator.collections.CountryTable;

/**
 * Country SQL record mapper.
 * 
 * @author Necro
 * @author Marek Snopkowski <snpy@snpy.info>
 * @version 11.04.2008
 */
public class Country extends Statement
{
    private static String[] countryNames = { "Polska", "Wielka Brytania" , "Niemcy" , "Francja" , "Egipt" , "Włochy" };
    private static String[] countryCodes = { "PL", "GB" , "DE" , "FR" , "EG" , "IT" };
        
    private int countryId;
    private String name;
    private String code;
    
    public static Country get(int idx)
    {        
        return new Country(idx + 1, countryNames[idx], countryCodes[idx]); 
    }
    
    public static int getTypesCount()
    {
        return countryNames.length;
    }

    @Override
    public int getId() {
        return countryId;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }
    
    public Country(int countryId, String name, String code)
    {
        this.countryId = countryId;
        this.name      = name;
        this.code      = code;
    }
    
    public Country(String name, String code)
    {
        this(CountryTable.autoincrement(), name, code);
    }
    
    public String getFieldsNameSet()
    {
        return "[country_id], [code], [name]";
    }
    
    public Object[] getFieldsValueCollection()
    {
        return new Object[]{ countryId, code, name };
    }
    
     @Override
    public String getTableName()
    {
        return "country";
    }
}
